FMemoryPool Class Reference

FMemoryPool provides a pool of equal sized cached memory blocks. More...

#include <fmemory.h>

Public Member Functions

 FMemoryPool (int32 maxElements, int32 elementSize)
 Constructor specifying the properties of the pool.
 ~FMemoryPool ()
 Destructor. Releases cached memory back to the heap.
void * newElement ()
 allocate an uninitialized memory block from the pool. If no unused block exists in the pool, allocate it from the heap.
void deleteElement (void *el)
 return a block, that has been allocated with newElement ()

Detailed Description

FMemoryPool provides a pool of equal sized cached memory blocks.

When a lot of equal sized objects are needed, FMemoryPool can be used for fast allocation. A standard application is overloading the new operator of a class that is often allocated and deallocated.

FMemoryPool starts empty and allocates requested memory blocks from the heap. If a block is returned to the pool, it is placed on top of a stack of cached objects that are used for fast handling of later allocations.

The number of objects that are kept in memory for fast re-use is given with the constructor. Requests beyond this threshold are returned to the heap.

FMemoryPool is thread safe, as it uses FLock to synchronize modifications to the pool.

See also:
FMemoryBlockPool

Constructor & Destructor Documentation

FMemoryPool ( int32  maxElements,
int32  elementSize 
)

Constructor specifying the properties of the pool.

Parameters:
[in] maxElements : the maximum number of unused memory blocks that are kept in memory
[in] elementSize : the size of each memory block. It must be greater than sizeof(void*).
~FMemoryPool (  ) 

Destructor. Releases cached memory back to the heap.


Member Function Documentation

void * newElement (  ) 

allocate an uninitialized memory block from the pool. If no unused block exists in the pool, allocate it from the heap.

void deleteElement ( void *  el  ) 

return a block, that has been allocated with newElement ()

 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines
Empty

Copyright ©2013 Steinberg Media Technologies GmbH. All Rights Reserved.